<html xmlns="http://www.w3c.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>DocRead Versão 1.0 - Login</title>
        <link href="#{appBean.baseUrl}resources/css/login.css" type="text/css" rel="stylesheet" />
    </h:head>
    <h:body>
        <div class="conteiner">
            	<p:growl id="growl" showDetail="true" life="3000" sticky="true"/>

            <h:form id="formLogin">  
                <p:growl id="growl" showDetail="true"/>  
                <div align="center">  

                    <p:panel header="DocRead - Autenticação" > 

                        <h:panelGrid columns="2" cellpadding="5">  
                            <h:outputLabel for="username" value="Usuário:" />  
                            <p:inputText value="#{loginBean.usuario.login}"   
                                         id="username" required="true" label="Usuário" />  

                            <h:outputLabel for="password" value="Senha: " />   
                            <p:password value="#{loginBean.usuario.senha}"   
                                        id="password" required="true" label="Senha" />                          
                            <f:facet name="footer">  
                                <div align="center">  

                                    <p:commandButton id="loginButton" value="Entrar" update="growl"   
                                                     actionListener="#{loginBean.login()}"   
                                                     oncomplete="handleLoginRequest(xhr, status, args)" />  </div>
                            </f:facet>  
                        </h:panelGrid>  
                    </p:panel>  
                </div>
            </h:form>
        </div>
        <script type="text/javascript">
            function handleLoginRequest(xhr, status, args) {
                if (args.validationFailed || !args.loggedIn) {
                    jQuery('#formLogin').parent().effect("shake", {times: 3}, 100);
                } else {
                    location.href = args.rota;
                }
            }
        </script>  
    </h:body>
</html>
